package com.example.qxfw.qxybzz.service.Impl;

import com.example.qxfw.qxybzz.entity.PageBean;
import com.example.qxfw.qxybzz.entity.dto.MessageDto;
import com.example.qxfw.qxybzz.entity.vo.MessageVo;
import com.example.qxfw.qxybzz.mapper.ProcessMapper;
import com.example.qxfw.qxybzz.service.ProcessService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import com.example.qxfw.qxybzz.service.ProcessService;

import java.time.LocalDateTime;
import java.util.List;

@Service
@RequiredArgsConstructor
public class ProcessServiceImpl implements ProcessService {

    private final ProcessMapper processMapper;


    @Override
    public PageBean getMessageList(Integer page, Integer pageSize, MessageDto messageDto) {

        PageHelper.startPage(page, pageSize);

        LocalDateTime sendtime = messageDto.getSendtime();
        String sender = messageDto.getSender();
        //发送状态
        Integer status = messageDto.getStatus();
        //处理结果：
        String result = messageDto.getResult();

        List<MessageVo> messageList = processMapper.getMessageList(messageDto);
        Page<MessageVo> pageMessageList = (Page<MessageVo>) messageList;

        PageBean pageBean = new PageBean(pageMessageList.getTotal(), pageMessageList.getResult());
        return pageBean;

    }

    @Override
    public void deleteMessage(Integer id) {
        processMapper.deleteMessage(id);
    }

    @Override
    public void deletePersons(Integer[] ids) {
        processMapper.deletePersons(ids);
    }

    @Override
    public void addMessage(MessageDto messageDto) {
        processMapper.addMessage(messageDto);
    }
}
